package com.sky.controller.test1;

import javax.swing.*;
import java.util.Arrays;
import java.util.Comparator;

public class Test10 {
    public static void main(String[] args) {
        JFrame win = new JFrame("登录窗口");
        JButton btn = new JButton("按钮");
        //给按钮设置大小
        btn.setBounds(100, 100, 100, 50);
        win.add(btn);

        win.setSize(400, 300);
        win.setLocationRelativeTo(null);
        win.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
        //监听按钮点击事件
        btn.addActionListener(e -> {
            System.out.println("点击了按钮");
        });
        win.setVisible(true);

    }
}
class mySort {
    public static void main(String[] args) {
        //创建一个学生数组
        Student[] students = new Student[5];
        students[0] = new Student("张三", 18);
        students[1] = new Student("李四", 25);
        students[2] = new Student("王五", 14);
        students[3] = new Student("赵六", 21);
        students[4] = new Student("钱七", 86);



        Arrays.sort(students, Comparator.comparingInt(Student::getAge));
        Arrays.sort(students, Comparator.comparingInt(Student::getAge).reversed());
        for (Student student : students) {
            System.out.println(student.getName() + ":" + student.getAge());
        }
    }
}
//写一个学生的类
class Student{
    private String name;
    private int age;

    public Student(String name, int age) {
        this.name = name;
        this.age = age;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }
}














